package com.controller;

import com.service.HystrixService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Description:
 *
 * @Autor: Rolin
 * datetime: 04-27-10:02
 */
@RestController
public class HystrixController {

    @Value("${server.port}")
    private String serverPort;

    @Resource
    private HystrixService hystrixService;

    @GetMapping("/payment/ok/{id}")
    public String hystrixTest(@PathVariable("id") Integer id) {
        return hystrixService.hystrix_ok(id);
    }

    @GetMapping("/payment/timeout/{id}")
    public String hystrixTest01(@PathVariable("id") Integer id) {
        return hystrixService.hystrix_timeout(id);
    }

    @GetMapping("/payment/error/{num}")
    public String hystrixTest03(@PathVariable ("num")Integer num){
        return hystrixService.circuitBreak(num);
    }
}

